@extends('layouts.admin.application')

@section('css')
    <link rel="stylesheet" href="/vendor/daterangepicker/daterangepicker.css">
@endsection

@section('content')

    <div class="admin-content">

        <div class="am-cf am-padding">
            <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">新增优惠券</strong> /
                <small>Create</small>
            </div>
        </div>
        <hr>
        @include('admin._flash')

        <div class="am-g">
            <div class="am-u-sm-12 am-u-md-12">

                <form class="am-form" action="/admin/coupon" method="post">
                    {{ csrf_field() }}


                    <div class="am-g am-margin-top">
                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                            所属门店
                        </div>
                        <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                            <select  data-am-selected="{btnWidth: '100%',  btnStyle: 'secondary', btnSize: 'sm', maxHeight: 360, searchBox: 1}"
                                     name="store_id">
                                <option value="">请选择</option>
                                @foreach($cates as $c)
                                    <option value="{{$c->id}}"@if($c->id==old('store_id')) selected @endif  >{{$c->name}}</option>
                                @endforeach
                            </select>
                        </div>
                    </div>

                    <div class="am-g am-margin-top">
                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                            适用范围
                        </div>
                        <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                            <th>@foreach($types as $t)
                                    <label class="am-btn am-btn-default am-btn-xs am-round" >
                                        <input type="checkbox" name="type_id[]" value="{{$t->id}}" > {{$t->name}}
                                    </label>
                                @endforeach
                            </th>
                        </div>
                    </div>

                    <div class="am-g am-margin-top">
                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                            优惠折度
                        </div>
                        <div class="am-u-sm-8 am-u-md-4">
                            <input type="text" class="am-input-sm" name="ratio"  value="{{old('ratio')}}" >
                        </div>
                        <div class="am-hide-sm-only am-u-md-6">*如7.5折则填写7.5</div>
                    </div>

                    <div class="am-g am-margin-top sort">
                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                            排序
                        </div>
                        <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                            <input type="text" name="sort" class="am-input-sm" value="{{old('sort')}}" >
                        </div>
                    </div>
                    <div class="am-g am-margin-top">
                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                            是否启用
                        </div>
                        <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                            <label class="am-radio-inline">
                                <input type="radio" value="1" name="is_use" checked> 是
                            </label>
                            <label class="am-radio-inline">
                                <input type="radio" value="0" name="is_use"> 否
                            </label>
                        </div>
                    </div>
                    <div class="am-g am-margin-top sort">
                        <div class="am-u-sm-4 am-u-md-2 am-text-right">
                            开始时间-结束时间
                        </div>
                        <div class="am-u-sm-8 am-u-md-4 am-u-end col-end">
                            <input type="text" name="date" id="date_start"  class="am-input-sm " value="{{old('date')}}"  placeholder="点击选择开始时间"  >
                        </div>
                    </div>
                    {{--<div class="am-g am-margin-top sort">--}}
                        {{--<div class="am-u-sm-4 am-u-md-2 am-text-right">--}}
                            {{--结束时间--}}
                        {{--</div>--}}
                        {{--<div class="am-u-sm-8 am-u-md-4 am-u-end col-end">--}}
                            {{--<input type="text" name="sort_order" class="am-input-sm" value="" placeholder="点击选择结束时间" >--}}
                        {{--</div>--}}
                    {{--</div>--}}










                    <div class="am-margin">
                        <button type="submit" class="am-btn am-btn-primary am-radius">提交保存</button>
                    </div>
                </form>
            </div>
        </div>
    </div>


@endsection
@section('js')
    <script src="/vendor/daterangepicker/moment.js"></script>
    <script src="/vendor/moment/locale/zh-cn.js"></script>
    <script src="/vendor/daterangepicker/daterangepicker.js"></script>

  <script>
      $(function () {
          //时间插件
          $('#date_start').daterangepicker({

              "autoUpdateInput": false,
              "autoApply": true,
              "locale": {
                  "format": "YYYY-MM-DD",
                  "applyLabel": "确定",
                  "cancelLabel": "取消"
              }
          }, function (start, end, label) {
              this.element[0].value = start.format('YYYY-MM-DD') + ' ~ ' + end.format('YYYY-MM-DD');
          });
      });

  </script>
@endsection